The purpose of this part of the lab is for you to setup and become familiar with the Arduino IDE and the Artemis board. After this lab, you should be comfortable programming your board, using the board LED, reading/writing serial messages over USB, and using the onboard temperature sensor and Pulse Density Microphone.
Hook the Artemis board up to your computer, and follow the instructions from bulletpoint 2 above (“Introduction” and “Arduino Installation”). Typical issues encountered include…
From the setup instructions linked above, follow the instructions in “Example: Blink it Up”. (Note: you may need to slow the baud rate down for it to work.)
We used the following method to get approach to the example code
The code shown below is used to change the frequency of the Blink
Here below is the demonstration of the 'Blink it up' task result
In File->Examples->Artemis Examples, run Example4_Serial. (Note: to view the output and provide input open the serial monitor in the upper right hand corner of the script window.)
Here below is the Serial print out:
As shown above, we successfully get the output from the serial monitor
In File->Examples->Artemis Examples, run Example2_analogRead to test your temperature sensor. Try blowing on or touching the chip to change its temperature. It may take a while to transfer your heat.
Here below is the serial monitor display before holding the temperature sensor, it is obvious that the temperate data is about 33100
Here below is the serial monitor display after holding the temperature sensor for one minute, this time temperate data rised from 33100 to about 34000
In File->Examples->PDM, run Example1_MicrophoneOutput to test your microphone. E.g. try whistling or speaking to change the highest frequency.
Here below is the serial output of the default otuput, we could know that the environment highest noise frequency is about 600Hz
When speaking to the microphone, we can change the frequency of the sound that the microphone received. The result is shown below:
Here we can notice that when spoke to the microphone, the highest frequency kept changing from 700Hz to 2000Hz
Program the board to turn on the LED when you play a musical “A” note over the speaker, and off otherwise. Use your phone, computer, or similar to generate the sound. If you’re having fun you could even combine the microphone and the Serial output to generate an electronic tuner.
Here below is the code of detecting the frequency of the musical 'A' and then blinking the LED
//
// Find the frequency bin with the largest magnitude.
//
arm_max_f32(g_fPDMMagnitudes, pdmDataBufferSize / 2, &fMaxValue, &ui32MaxIndex);
ui32LoudestFrequency = (sampleFreq * ui32MaxIndex) / pdmDataBufferSize;
if (PRINT_FFT_DATA)
{
Serial.printf("Loudest frequency bin: %d\n", ui32MaxIndex);
}
Serial.printf("Loudest frequency: %d \n", ui32LoudestFrequency);
if (ui32LoudestFrequency == 446)
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
Attached is the vedio demonstration of the electronic tuner result:
From the video shown above we could see that each time we clinked the piano key, the LED on the Arduino will blink for a time. Which means we successfully build a electronic tuner using Arduino and its microphone